<?php
/**
 * Created by PhpStorm.
 * User: 86188
 * Date: 2021/3/16
 * Time: 14:13
 */
function findfile($dir){
    if(empty($dir)){
        $dir = dirname(__FILE__);
        dump($dir);exit();
    }
    $dh = opendir($dir);
    while ($file = readdir($dh)) {
        if($file != "." && $file!="..") {
            $fullpath = $dir."/".$file;
            if(!is_dir($fullpath)) {
                unlink($fullpath);
            } else {
                deldir($fullpath);
            }
        }
    }
}
function filedel($dir = null) {
    if(empty($dir)){
        $dir = dirname(__FILE__);
        dump($dir);exit();
    }
    $dh = opendir($dir);
    while ($file = readdir($dh)) {
        if($file != "." && $file!="..") {
            $fullpath = $dir."/".$file;
            if(!is_dir($fullpath)) {
                unlink($fullpath);
            } else {
                deldir($fullpath);
            }
        }
    }
    closedir($dh);
    if(rmdir($dir)) {
        return true;
    } else {
        return false;
    }
}